﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IURIP;
using System.Xml;
using URIP.Tool;

namespace URIP.Core
{
    public class DataBlock : IDataBlock
    {
        public DataBlock(ITarget target)
        {
            m_target = target;
        }

        private ITarget m_target = null;
        private string m_name = "";
        private string m_from = "";

        public ITarget Target
        {
            get { return m_target; }
        }

        public string Name
        {
            get { return m_name; }
        }

        public string From
        {
            get { return m_from; }
        }

        public void InitByConfiguration(XmlNode node)
        {
            this.m_name = Util.GetAttributeValue(node, "name");
            if (string.IsNullOrEmpty(m_name))
            {
                throw new Exception(string.Format("The DataBlock defined has no valid 'name' attribute."));
            }
            this.m_from = Util.GetAttributeValue(node, "from");
            Target.Task.Logger.LogInfo(string.Format("The 'from' attribute for DataBlock '{0}' is {1}.", m_name, m_from));
        }
    }
}
